<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        canvas{border: 1px solid #aaa;}
    </style>
</head>
<body>

<canvas width="600" height="400" class="myCanvas">
    当前的浏览器版本不支持，请升级浏览器
</canvas>
<script>
    var canvas = document.getElementsByClassName('myCanvas')[0];
    var ctx = canvas.getContext('2d');

    //创建一个路径
    ctx.beginPath();
    //移动的开始点
    ctx.moveTo(100,100);
    //描述行进路径
    ctx.lineTo(200,150);
    ctx.lineTo(150,210);
    //封闭路径
    ctx.closePath();
    //绘制这个不规则图形
    ctx.strokeStyle="red";
    ctx.stroke();
</script>

</body>
</html>
